import QtQuick 2.5
import QtQuick.Controls 2.1
import ".."

Popup
{
    id: myOns
    height: 120
    width: 600
    x: 212
    y: 0
    property alias contentText: content.text
    background: Rectangle
    {
        color: Common.colorTransParent
    }
    Rectangle
    {
        id: ons
        width: 600
        height: 0
        radius: 4
        anchors.top: parent.top
        anchors.horizontalCenter: parent.horizontalCenter
        color: Qt.rgba(1, 0, 0, 0.8)
        Behavior on height {PropertyAnimation {duration: 100}}
        onVisibleChanged:
        {
            if(visible)
            {
                ons.height = 120
                autoClose.start()
            }
            else ons.height = 0
        }
        Text
        {
            id: content
            visible: parent.height == 120
            anchors.fill: parent
            anchors.topMargin: 30
            anchors.leftMargin: 40
            anchors.rightMargin: 40
            anchors.bottomMargin: 30
            verticalAlignment: Text.AlignHCenter
            horizontalAlignment: Text.AlignHCenter
            font.family: Common.fontMain
            font.pixelSize: 24
            color: "white"
        }
        Timer
        {
            id: autoClose
            interval: 5000
            repeat: false
            onTriggered:
            {
                myOns.visible = false
            }
        }
    }
    MouseArea
    {
        id: buttonArea
        anchors.fill: parent
        hoverEnabled: true
        onClicked:
        {
            autoClose.stop()
            myOns.visible = false;
        }
    }
}

